from datetime import date,datetime
class User:
    def __init__(self,name,birthday):
        self.name=name
        self.birthday=birthday
        self._age=0

    def get_age(self):
        return datetime.now().year-self.birthday.year

    @property
    def age(self):
        return datetime.now().year-self.birthday.year

    @age.setter
    def age(self,value):
        self._age=value#不想让这个属性在代码中显示出来,user._age不会有提示

if __name__ == '__main__':
    user=User('AK',date(year=2001,month=4,day=29))
    res=user.get_age()
    print(res)
    print(user.age)
    user.age=18
    print(user._age)


